package com.cow.framework.core.config.dict;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cow.framework.core.base.BaseComponent;


/**
 * 数字字典管理
 *
 * @author yangsj 
 **/
@RestController
@EnableAutoConfiguration
@RequestMapping(value="/config/dict")
public class DictController extends BaseComponent{
	@Autowired
	DictUtil dictUtil;
	
	/**获取枚举列表*/
	@RequestMapping(value="/getDict")	
	public Object getDict(@RequestParam String dictName) throws Exception{		
		return dictUtil.getDict(dictName);
	}
	
	/**获取枚举列表*/
	@RequestMapping(value="/getDictIncludeNull")	
	public Object getDictIncludeNull(@RequestParam String dictName) throws Exception{	
		Map map = dictUtil.getDict(dictName);
		map.put("9999", "空");
		return dictUtil.getDict(dictName);
	}
	
	/**获取枚举代码名*/
	@RequestMapping(value="/getDictValueName")	
	public Object getDictValueName(@RequestParam String dictName,@RequestParam String value) throws Exception{		
		return dictUtil.getDictValueName(dictName, value);
	}
	
	/**获取枚举列表*/
	@RequestMapping(value="/getDicts")	
	public Object getDicts(@RequestParam String dictNames) throws Exception{
		return dictUtil.getDictValueNames(dictNames);
	}
}
